package com.peanut.server.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.peanut.dto.TabItemDTO;
import com.peanut.mapper.TabCarSellInformationMapper;
import com.peanut.pojo.TabItem;
import com.peanut.server.SubmitInformationService;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

@Service
public class SubmitInformationServiceipml implements SubmitInformationService {
    @Resource
    TabCarSellInformationMapper tabCarSellInformationMapper;

    @Override
    public TabItemDTO tabCarSellInformationById(Long id) {
        TabItemDTO tabCarSellInformationDTO = new TabItemDTO();
        QueryWrapper<TabItem> tabParameterBasicQueryWrapper = new QueryWrapper<>();
        tabParameterBasicQueryWrapper.eq("id", id);
        List<TabItem> tabItems = tabCarSellInformationMapper.selectList(tabParameterBasicQueryWrapper);
        TabItem tabCarSellInformation = tabItems.get(0);
        try {
            BeanUtils.copyProperties(tabCarSellInformationDTO, tabCarSellInformation);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return tabCarSellInformationDTO;
    }
}
